<!DOCTYPE html>
<html>
<head lang="en">
    <title>我的收藏</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/bootstrap-4.1.1-dist/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/strategy.css"/>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css"/>
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script src="/js/common.js"></script>

</head>
<script>
    $(function () {
        var userId = JSON.parse(sessionStorage.getItem("user")).id;
        var type;
        var pages;
        var currentPage = 1;
        $.get("/collects/userlikes", {currentPage: currentPage, userId: userId, type: 1}, function (data) {
            console.log(data);
            $(".strategies").renderValues(data, {
                getHref: getHref
            });
        })

        function query() {
            $.get("/collects/userlikes", {currentPage: currentPage, userId: userId, type: type}, function (data) {
                if (type = 1) {
                    $(".strategies").renderValues(data, {
                        getHref: getHref
                    });
                    pages = data.pages;
                    currentPage ++;
                }
                if (type = 2) {
                    $(".travels").renderValues(data, {
                        getHref: getHref
                    });
                    pages = data.pages;
                    currentPage ++;

                }
                if (type = 3) {
                    $(".daily").renderValues(data, {
                        getHref: getHref
                    });
                }
                pages = data.pages;
                currentPage++;
            })
        }
        $(".clickTab").click(function () {
            type = $(this).data("type");
            query();
        })
        //监听滚动事件
        $(window).scroll(function () {
            if (($(document).scrollTop() + $(window).height()) >= $(document).height() - 1) {
                if (currentPage <= pages) {
                    query();
                } else {
                    $(document).dialog({
                        type: 'notice',
                        infoText: '亲, 到底了!',
                        autoClose: 1000,
                        position: 'bottom'  // center: 居中; bottom: 底部
                    });
                }
            }
        });
    });
</script>
<body>
<div class="search-head">
    <div class="row nav-search">
        <div class="col">
            <a href="javascript:window.history.go(-1)">
                <span><i class="fa fa-chevron-left"></i></span>
            </a>
        </div>
        <div class="col">
            <span>我的收藏</span>
        </div>
        <div class="col"></div>
    </div>
</div>

<ul class="nav nav-pills nav-justified border border-left-0 border-top-0 border-right-0" id="pills-tab" role="tablist">
    <li class="nav-item" style="width: 33%">
        <a role="button" id="strategy" class="nav-link clickTab active show" data-type="1" data-toggle="pill"
           href="#pills-strategy">
            <span class="strategy">攻略</span>
        </a>
    </li>
    <li class="nav-item" style="width: 33%">
        <a role="button" id="travel" class="nav-link clickTab show" data-type="2" data-toggle="pill" href="#pills-travel">
            <span class="travel">游记</span>
        </a>
    </li>
    <li class="nav-item" style="width: 33%">
        <a role="button" id="daily" class="nav-link clickTab show" data-type="3" data-toggle="pill" href="#pills-daily">
            <span class="daily">日报</span>
        </a>
    </li>
</ul>
<div class="tab-content" id="pills-tabContent">
    <div class="tab-pane fade active show strategies" id="pills-strategy">
        <div render-loop="list">
            <div class="container commend">
                <a data-href="/strategyCatalogs.html?id=" render-fun="getHref" render-key="list.strategy.id">
                    <p render-html="list.strategy.title"></p>
                    <img width="60%"
                         render-src="list.strategy.coverUrl">
                </a>
            </div>
            <hr>
        </div>
    </div>
    <div class="tab-pane fade active show travels" id="pills-travel">
        <div render-loop="list">
            <div class="container commend">
                <a data-href="/travelContent.html?id=" render-fun="getHref" render-key="list.travel.id">
                    <p render-html="list.travel.title"></p>
                    <img width="60%"
                         render-src="list.travel.coverUrl">
                </a>
            </div>
            <hr>
        </div>
    </div>
    <div class="tab-pane fade active show daily" id="pills-daily">
        <div render-loop="list">
            <div class="container commend">
                <a data-href="/newsContent.html?id=" render-fun="getHref" render-key="list.daily.id">
                    <p render-html="list.daily.title"></p>
                    <img width="60%"
                         render-src="list.daily.coverUrl">
                </a>
            </div>
            <hr>
        </div>
    </div>
</div>
</div>
</body>
</html>
